package com.sky.controller.user;

import com.sky.config.JsonRedisTemplate;
import com.sky.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController("userShopController")
@RequestMapping("user/shop")
@Api(tags = "C端-店铺相关接口")
@Slf4j
public class ShopController {

    private final JsonRedisTemplate jsonRedisTemplate;
    public ShopController(JsonRedisTemplate jsonRedisTemplate) {
        this.jsonRedisTemplate = jsonRedisTemplate;
    }


    @GetMapping("/status")
    @ApiOperation("获取店铺的营业状态")
    public Result<Integer> getStatus(){
        Integer status = jsonRedisTemplate.opsForValue().get("SHOP_STATUS") == null ? Integer.valueOf(1) :(Integer)jsonRedisTemplate.opsForValue().get("SHOP_STATUS");
        log.info("获取店铺的营业状态为: {}",status == 1?"营业中":"打烊中");
        return Result.success(status);

    }

    @GetMapping("/getMerchantInfo")
    @ApiOperation("获取商户信息")
    public Result<Map<String, Object>> getMerchantInfo(){
        HashMap<String, Object> map = new HashMap<>();
        map.put("phone","18449546660");
        return Result.success(map);
    }
}
